package cn.wsalix.observable.service.impl;

import java.util.Observable;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.wsalix.observable.service.ProductChangeService;
import cn.wsalix.shop.form.ProductForm;
import cn.wsalix.shop.service.BrandService;
import cn.wsalix.shop.service.OriginService;
import cn.wsalix.shop.service.ProductService;
@Service("productChangeService")
public class ProductChangeServiceImpl extends Observable implements ProductChangeService {
	private static final Logger logger = LoggerFactory
			.getLogger(ProductChangeServiceImpl.class);
	@Autowired
	private ProductService productService;
	@Autowired
	private BrandService brandService;
	@Autowired
	private OriginService originService;

	@PostConstruct  
	public void init() {  
		logger.info("==========init");  
		//addObserver(productStandard);
		//addObserver(originService);
//		/addObserver(brandService);
		//addObserver(productService);
	}  
	@Transactional
	public void change(ProductForm form) {		
		setChanged();
		notifyObservers(form);
	}

	@PreDestroy  
	public void destroy() {  
	    logger.info("==========destroy");  
	}  
}
